'use strict';{let v=new _0g,z;var _ca=_Et(function*(){_Td(_2i.menuStyle);_Td(_Ot.menuStyle);_So(_p,[yield _lj(yield _ta("/res/swtchOff.svg",16,16)),yield _lj(yield _ta("/res/swtchOn.svg",16,16))]);_q(yield _ta("/res/actionIcon.svg",16,16),a=>z=a);v&&v.send()});_ca();var _Zy=function(a,b=_Jr.items){return b&&b[a]};let A=_wj(function*(a,b,e){let d=_Jr.items,h=d.length,k=[];var g=0;let l=b.commonOptions||{};const n=l.withPreviews?_Dk:l.thumbSize;var f=l.sc().del("maxItems"),m=b.sc().keep("break","sepLine");
const q=f.noTitles;if(b.type.in("TSE","tabGroups")){let c="TSE"==b.type?yield _fr(e,_4j,b.content):b.content;for(let p of c){const r=!g++;k.push({noTitle:q,title:p.length+" tabs",icon:"res/tabs.png",subMenu:!0,itemType:_Wi}.add(r?m:null));d.push({type:"tabList",content:p,commonOptions:f}.add(r?m:null))}1==c.length&&(b=d.pop(),k=[],g=0)}if("tabList"==b.type)for(let c of b.content)f={noTitle:q,title:_os[c].title,icon:_Tu(_7j(_os[c])),itemType:_6g},0==g++&&f.add(m),n&&f.add({previewId:c,thumbSize:n}),
k.push(f),d.push({type:"tab",content:c});else if(b.type.in("closedTabs","closedWin")){a="closedWin"==b.type?b.content.tabs:_Ky.sessions?(yield c=>_Ky.sessions.getRecentlyClosed(c)).map(c=>c.tab||c.window):[];for(let c of a)a={noTitle:q,title:c.tabs?c.tabs.length+" tabs":c.title,icon:c.tabs?"res/tabs.png":_Tu(c.url),subMenu:c.tabs?!0:void 0,itemType:c.tabs?_5o:_Dj},0==g++&&a.add(m),n&&!c.tabs&&a.add({previewId:+c.sessionId,thumbSize:n}),k.push(a),d.push({type:c.tabs?"closedWin":"closedTab",content:c,
commonOptions:c.tabs?f:void 0})}else if(b.type.in("bmFolder","bmSubFldr")){a=_Ky.bookmarks&&(yield c=>_Ky.bookmarks.getChildren(b.content+"",c))||[];for(let c of a)k.push({noTitle:q,title:c.title,icon:c.url?_Tu(c.url):"res/folder.png",subMenu:!c.url,itemType:c.url?_ur:_ys}.add(g++?null:m)),d.push({type:c.url?"bookmark":"bmSubFldr",content:c.id,commonOptions:c.url?void 0:f})}else if("custom"==b.type){g=new x;for(let c of b.content)if(g=g.addNeighbor(1),c.subMenu||c.type.in("custom","action","switch")){let p,
r,w,t;if("TSE"==c.type)p=_er(c.content,"tse").name||"(Unnamed tab selection)",r="res/tabs.png",w=!0,t=y(c.type);else if("closedTabs"==c.type)p=c.title||"Closed tabs",r="res/tabs.png",w=!0,t=y(c.type);else if("custom"==c.type)p=c.title||"(Unnamed submenu)",w=!0;else if("bmFolder"==c.type){if(m=(_Ky.bookmarks&&(yield E=>_Ky.bookmarks.get(c.content+"",E))||[])[0])p=m.title,r="res/folder.png",w=!0,t=y(c.type)}else if("action"==c.type)(m=yield _qf("trigActList",c.content))&&!m.disabled&&(p=m.title||"(Unnamed action)",
r=m.icon&&m.icon.img||z,t=_5t);else if("switch"==c.type&&c.content){p=_er(c.content).name;t=_yo;var F=+_Uk(c.content)[1]}p&&(k.push({noTitle:q,title:p,icon:r,itemType:t,switchId:F,subMenu:w,break:c.break,sepLine:c.sepLine}),m={commonOptions:f.sc().add(c.commonOptions)}.add(c.sc().del("commonOptions","break","sepLine"),{parentID:a,itemIdx:g}),d.push(m))}else m={commonOptions:f.sc().add(c.commonOptions)}.add(c.sc().del("commonOptions")),m=yield A(a,m,e),k.push(...m)}l.maxItems&&(d.splice(h+l.maxItems),
k.splice(l.maxItems));return k}),y=a=>({TSE:_Wi|_5,bmFolder:_ys|_5,closedTabs:_th})[a]||_7h,B=_wj(function*(a,b,e){a=yield A(a,b,e);b=b.commonOptions||{};var d=a.length,h=b.itemsDistrib&&b.itemsDistrib[0]?b.itemsDistrib:b.layout!=_or("R")?["numGroups"]:["auto"];d="auto"==h[0]?Math.ceil(Math.sqrt(d)):"numGroups"==h[0]?Math.ceil(d/(h[1]||1)):h[1]||1;let k=new _do;h=0;let g=!0;for(let l of a)l.break&&(h=0),l.break=0!=h||g?void 0:!0,l.icon&&_lj(l.icon)(k.onReady(n=>l.icon=n)),g=!1,h=++h%d;yield l=>k.setCallback(l);
_Jr.trigInstId=e;return{style:"std",items:a}.add(b)}),G=(a,b)=>{try{B(a,_Jr.items[a],_Jr.trigInstId)(e=>_ay(b,e))}catch(e){_6p("menuError",{stack:e.stack}),_ay(b,[])}},C=(a,b,e)=>a==b?e:a==e?b:a;var _rf=_wj(function*(a,b,e,d=!1){v&&(yield v.wait(),v=void 0);if(!_Jr.items||(yield H())){_Jr={items:[null],busy:!0};var h=b.rootOptions||{},k=h.position||"mouse";if(yield _fw(_Ur,{menuData:yield B(a,b,e),menuEntityNum:_Eg(a),position:_or(k[0].toUpperCase()),alignHorz:"mouse"==k?C(h.alignHorz,_S,_gd):h.alignHorz,
alignVert:"mouse"==k?C(h.alignVert,_Io,_Zd):h.alignVert,menuSystem:h.menuSystem,usePrvMsPos:d}))_Jr.id=a;delete _Jr.busy}});let u,H=()=>(a=_Qu)=>{u=b=>{u=null;a(b)};_So(_Mi,null,b=>{b||u&&u(!1)})||_co(_sf)},I=a=>{a&&(_Kp={[_Jr.id]:Date.now()});_Jr.busy||(_Jr={});u&&u(!0)};{const a=[{action:"alterTgtTabs",params:{tse:[{oper:"slice",params:{from:1,to:1}}]}},{action:"activateTabs"}],b=(e,d)=>[{sequence:[{action:"loadUrls",params:{bookmarkId:e}.add(d?{tabPos:"after",refTab:"lastTab"}:null)}].concat(2==
d?a:[]),targets:"currentTab"}];var _Pe=_wj(function*(e,d=0){const h=_Jr.items;let k=_Zy(e,h);if(k){yield _Co();const g=k.type,l=k.content;let n;if("action"==g)2!=d&&(n=yield _Ji(_Sg[l]||[],null,_3o(null,{usePrevMousePos:!0})));else if("switch"==g)2!=d&&_es(l,-1);else if("bookmark"==g)e=b(l,d),n=yield _Ji(e);else if("bmFolder"==g||"bmSubFldr"==g)0!=d&&(n=yield _Ji(b(l,d)));else if("TSE"==g||"tabList"==g){if(2==d){let f="TSE"==g?yield _fr(h.trigInstId,_4j,l):_Vs(l);yield m=>_Zu(f,m);_So(_Af,e)}}else"tab"==
g?2==d?(yield f=>_Zu(_Vs(l),f),_So(_Af,e)):(n=yield f=>_pi(_Vs(l),f),yield f=>_Tt(n,f)):"closedTabs"!=g&&("closedWin"==g?0!=d&&(d=yield f=>_Ky.sessions.restore(l.sessionId,f),n=(_Kg(d,"window","tabs")||[]).map(f=>f.id),_So(_Af,e)):"closedTab"==g&&2!=d&&(d=yield f=>_Ky.sessions.restore(l.sessionId,f),(d=_Kg(d,"tab","id"))&&(n=[d]),_So(_Af,e)));_Fo=!0;return n}})}let J=_wj(function*(a){let b=_Zy(a,_Jr.items);if(b)switch(b.type){case "bookmark":return _Kg(yield e=>_Ky.bookmarks.get(b.content+"",e),0,
"url");case "tab":return _7j(_os[b.content]);case "closedTab":return b.content.url}}),D=(a,b)=>{let e=[];for(;a;){e.unshift("content",a.itemIdx);if("string"==typeof a.parentID){e.unshift(a.parentID);break}a=_Zy(a.parentID,b)}return e},K=_wj(function*(a,b,e,d){var h=_Jr.items;let k=_Zy(a,h),g=4294967294==b?{parentID:e,itemIdx:new x}:_Zy(b,h);if(k&&g){if(k.type.in("bookmark","bmSubFldr")){if(4294967294==b)var l={parentId:_Zy(e,h).content};else(b=_Kg(yield f=>_Ky.bookmarks.get(g.content,f),0))&&(l={parentId:b.parentId,
index:b.index+("B"==d?1:0)});return l&&(yield f=>_Ky.bookmarks.move(k.content,l,f))}e=D(k,h);var n=D(g,h);h=e[0];if(_xp(h)&&!n.join(" ").startsWith(e.join(" "))){a=_er(h).value;e=_Kg(a,...e.slice(1,-1));n=_Kg(a,...n.slice(1,-1));let f=e[k.itemIdx],m=n[g.itemIdx],q=e[k.itemIdx+1];q&&(f.sepLine&&(q.sepLine=!0),f.break&&(q.break=!0));f.del("sepLine","break");4294967294==b&&(d="B");"T"==d&&(m.sepLine&&(f.sepLine=!0),m.break&&(f.break=!0),m.del("sepLine","break"));d="B"==d?1:0;e.remove(f);n.splice(n.indexOf(m)+
d,0,f);k.parentID=g.parentID;k.itemIdx.remove();k.itemIdx=g.itemIdx.addNeighbor(d);_we([h,"value"],a,0);return!0}}}),x=function(a,b){this.list=a?a.list:[];null!=b&&this.list.splice(a+b,0,this)};x.prototype={valueOf(){return this.list.indexOf(this)},toString(){return+this},addNeighbor(a){return new x(this,a)},remove(){this.list.splice(+this,1)[0].list=null}};let L=(a,b)=>[];_tr({[_Wk]:a=>G(a.itemId,a.callback),[_0t]:a=>J(a.itemId)(b=>_ay(a.callback,b)),[_wg]:a=>K(a.srcItmId,a.tgtItmId,a.tgtParentId,
_Iy(a.insertPos))(b=>_ay(a.callback,!!b)),[_Ry]:a=>_Pe(a.itemId,a.selMode)(),[_eg]:a=>_ay(a.callback,L(a.itemId,a.parentId)),[_sf]:a=>I(a&&a.click)})};
